package kr.ac.ml.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ac.kr.ml.dao.ContentListDao;
import ac.kr.ml.dao.ListDao;
import ac.kr.ml.dao.UserDao;
import ac.kr.ml.vo.ContentVo;
import ac.kr.ml.vo.FriendVo;
import ac.kr.ml.vo.WriteVo;
import kr.ac.ml.mvc.Action;
import kr.ac.ml.mvc.HttpUtil;



public class MainAction extends Action {

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		
		
System.out.println("mainAction");
		
		String keyStr = request.getParameter("key");
		int key = Integer.parseInt(keyStr);		
		
		UserDao dao = new UserDao();
		
		List<FriendVo> friendList = dao.getFriend(key);
		
		ContentListDao dao2 =  new ContentListDao();
		List<WriteVo> list =  dao2.getAllList(key, friendList);
		
		request.setAttribute("list", list);	
		request.setAttribute("state", "main");
		HttpUtil.forward(request, response, "/views/main.jsp");
	}

}
